<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>object methods</title>
</head>
<body>
    
    <script>
        
        {
            // 合并对象  Object.assign(target,source)

            let source = {
                a: 'this is a',
                b: function () {
                    console.log('this is b function');
                }
            };

            let target = {
                c: function () {
                    console.log('target');
                }
            }

            Object.assign(target,source);

            console.log(target);
            console.log(target.b());

        }


        {
            // 创造对象 Object.create()

            function A (a) {
                this.a = a;
                this.b = function () {
                    console.log('b');
                }
            }

            A.prototype = {
                c: function () {
                    console.log('c');
                }
            };

            let a = new A('a');

            let b = Object.create(a);
            console.log(b.b());

        }
    
    </script>

</body>
</html>